<template>
  <a-modal
    :title="title"
    :visible="visible"
    :confirm-loading="confirmLoading"
    cancel-text="关闭"
    @ok="submit"
    @cancel="closeModal"
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="新密码">
          <a-input v-decorator="['pwd', validatorRules.pwd ]" placeholder="请输入新密码" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import ApiTree from '@/api/merchant/merchantList';
import ImageUpload from '@/components/ImageUpload';
import { Slime } from '@/mixins/slime';
export default {
  name: 'merchantPwdModal',
  components: { ImageUpload },
  data() {
    return {
      title: '修改密码',
      form: this.$form.createForm(this),
      model:{},
      validatorRules: {
        pwd: { rules: [{ required: true, message: '请输入新密码!' }] },
      },
    };
  },
  mixins: [Slime],
  methods: {
    // 详情
    open(record) {
      this.visible = true;
    },
    // 提交
    submit() {
      const that = this;
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          const param = {...values, ...that.model};
          that.submitUpdate(param);
        }
      });
    },
    // 提交 改
    submitUpdate(param) {
      const that = this;
      ApiTree.resetPwd(param)
        .then((res) => {
          that.$message.success('重置成功');
        })
        .finally(() => {
          that.closeModal();
        });
    },
    // 弹窗-关闭
    closeModal() {
      this.confirmLoading = false;
      this.visible = false;
      this.form.resetFields();
      this.$emit('closeModal');
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>